package com.example.administrator.zhongyichou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.zhongyichou.R;
import com.example.administrator.zhongyichou.net.protocol.MillionsJoinProtocol;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by lichenyu on 2017/12/8.
 * 描述：
 */

public class MillionsJoinAdapter extends ListBaseAdapter {

    public MillionsJoinAdapter(Context mContext, List list) {
        super(mContext, list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.millions_join_list_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        MillionsJoinProtocol.DataBean bean = (MillionsJoinProtocol.DataBean) getData(position);
        if (bean.isSelect()) {
            holder.txtSelect.setImageResource(R.mipmap.select_p);
        } else {
            holder.txtSelect.setImageResource(R.mipmap.select_n);
        }
        holder.txtName.setText(bean.getMember_name());
        holder.txtId.setText(bean.getMember_num());
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.txt_name)
        TextView txtName;
        @BindView(R.id.txt_id)
        TextView txtId;
        @BindView(R.id.txt_select)
        ImageView txtSelect;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
